/*********************************************************
 * Cameron Hilton
 * CS362_400
 * 
 * Test to see if end of turn is handled properly in endTurn() function
 ********************************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
    
    int seed = 1000;
    int numPlayer = 2;
    int handCount;
    int coin_num;
    
	struct gameState state;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	initializeGame(numPlayer, k, seed, &state);

	// test endTurn for various hand sizes
	for (handCount = 0; handCount <= 10; handCount++) {
		memset(&state, 23, sizeof(struct gameState)); // reset game state
		initializeGame(numPlayer, k, seed, &state);

		printf("Testing endTurn for hand size %d\n", handCount);

		assert(endTurn(&state) == 0); // make sure function returns expected value
		assert(state.outpostPlayed == 0);
		assert(state.phase == 0);
		assert(state.numActions == 1);
		assert(state.numBuys == 1);
		assert(state.playedCardCount == 0);
		assert(state.handCount[state.whoseTurn] == 5); // make sure proper number of card redrawn
		
		coin_num = state.coins;
		updateCoins(state.whoseTurn, &state, 0);
		assert(state.coins == coin_num); // make sure coin count was updated
	}

    printf("All tests passed!\n");

    return 0;
}